﻿Imports System.Data
Imports System.Data.SqlClient

Public Class PhanCongDAO
    Private dataProvider As DataProvider
    Private sqlstr As String
    Public Sub New()
        dataProvider = New DataProvider
    End Sub
    Public Shared Function GetData() As DataTable
        Dim dt As DataTable = dataProvider.Executequery("sp_XuatSV")
        Return dt
    End Function


    Public Shared Sub ThemPC(ByVal pc As PhanCongDTO)
        Dim cn As SqlConnection = dataProvider.GetConnection()
        cn.Open()
        Dim cmd As SqlCommand = New SqlCommand("sp_ThemSinhVien")
        cmd.CommandType = CommandType.StoredProcedure
        cmd.Parameters.Add("@MaGiangVien", SqlDbType.VarChar, 10)
        cmd.Parameters.Add("@MaMonHocMo", SqlDbType.Int)

        cmd.Parameters("@MaGiangVien").Value = pc.MaGiangVien
        cmd.Parameters("@MaMonHocMo").Value = pc.MaMonHocMo

        cmd.ExecuteNonQuery()
        cn.Close()
    End Sub

    Public Function DeleteCustomer(ByVal qlPCDTO As PhanCongDTO)
        Dim maGV As String = qlPCDTO.MaGiangVien
        sqlstr = "DELETE Customer WHERE CustomerId='" & maGV & "'"
        Return dataProvider.Excute(sqlstr)
    End Function
End Class
